package com.example.design.singletonDemo;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SerializeSigleton {
    public static void main(String[] args) throws Exception {
        Singleton3 singleton3 = Singleton3.getSingleton3();
        FileOutputStream fos = new FileOutputStream("D:\\code\\Singleton.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(singleton3);
        oos.flush();
        oos.close();

        FileInputStream fis = new FileInputStream("D:\\code\\Singleton.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Singleton3 singleton2 = (Singleton3) ois.readObject();
        System.out.println(singleton2==singleton3);

    }


}
